package com.tutu.service.impl;

import com.tutu.core.Constant;
import com.tutu.core.api.AlarmMessageApiUrls;
import com.tutu.service.CodeDictService;
import com.tutu.service.StatisticService;
import com.tutu.utils.*;
import net.sf.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class StatisticServiceImpl implements StatisticService {

    @Autowired
    CodeDictService codeDictService;

    @Override
    public Map<String, Object> findListByParams(Integer companyId, String deviceCode, Integer type, String keyWord, String startTime, String endTime) {
        if (null == companyId) return BaseUtil.defaultPageErrorInfo();

        return HttpRequestUtil.getOnlyData(AlarmMessageApiUrls.base_prefix + AlarmMessageApiUrls.findListByParams, "companyId=" + companyId + "&deviceCode=" + deviceCode + "&type=" + type + "&startTime=" + DateUtils.stringToLongWithFormat(startTime, Constant.TIME_FORMAT_DEFAULT) + "&endTime=" + DateUtils.stringToLongWithFormat(endTime, Constant.TIME_FORMAT_DEFAULT) + "&keyWord=" + UnicodeUtil.unicodeEncode(keyWord));
    }
}